//
//  DoctorDetailsController.m
//  7-11快医
//
//  Created by amor on 16/7/12.
//  Copyright © 2016年 amor. All rights reserved.
//

#import "CJTDoctorDetailsController.h"
#import <UIImageView+WebCache.h>
#import "CJTDoctorCollectionCell.h"


static NSString * const Identifier = @"collectionViewCell";

@interface CJTDoctorDetailsController ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *doctorImage;

@property (weak, nonatomic) IBOutlet UILabel *doctorName;

@property (weak, nonatomic) IBOutlet UILabel *doctorPosition;

@property (weak, nonatomic) IBOutlet UILabel *doctorHospital;

@property (weak, nonatomic) IBOutlet UIButton *orderButton;

@property (weak, nonatomic) IBOutlet UIButton *flowerButton;

@property (weak, nonatomic) IBOutlet UIButton *flagButton;


@property (weak, nonatomic) IBOutlet UICollectionView *homepageCollection;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *layout;

@property (weak, nonatomic) IBOutlet UIButton *conditionButton;
@property (weak, nonatomic) IBOutlet UIButton *summaryButton;

@property (weak, nonatomic) IBOutlet UIButton *timeButton;


@end

@implementation CJTDoctorDetailsController



-(void)viewDidLoad{
    [super viewDidLoad];
    //赋值
    [self setAssignment];
    
    
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self setCollectionView];
    
    
}


#pragma mark - 赋值
-(void)setAssignment{
    [self.doctorImage sd_setImageWithURL:[NSURL URLWithString:self.arrayData.doctor_portrait] placeholderImage:[UIImage imageNamed:@"illness_img_person.png"] options:SDWebImageRetryFailed];
    self.doctorImage.layer.masksToBounds = YES;
    self.doctorImage.layer.cornerRadius = 30;
    self.doctorName.text = self.arrayData.doctor_name;
    self.doctorPosition.text = self.arrayData.doctor_title_name;
    self.doctorHospital.text = self.arrayData.doctor_hospital_name;
    
    [self.flowerButton setTitle:[NSString stringWithFormat:@"  %ld",(long)self.arrayData.flower] forState:UIControlStateNormal];
    [self.orderButton setTitle:[NSString stringWithFormat:@"  %ld",(long)self.arrayData.banner] forState:UIControlStateNormal];
    [self.flagButton setTitle:[NSString stringWithFormat:@"  %ld",(long)self.arrayData.operation_count] forState:UIControlStateNormal];
}


- (UIColor *)randomColor{
    return [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1];
}
-(void)setCollectionView{
    // 设置collectionView的背景色
    //    self.homepageCollection.backgroundColor = [self randomColor];
    
    // 设置itemSize
    self.layout.itemSize = self.homepageCollection.bounds.size;
    
    // 设置滚动方向
    self.layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    // 设置间隔
    self.layout.minimumLineSpacing = 0;
    
    // 打开分页效果
    self.homepageCollection.pagingEnabled = YES;
    
    // 关闭水平滚动条
    //    self.homepageCollection.showsHorizontalScrollIndicator = NO;
    
    // 关闭弹簧效果
    self.homepageCollection.bounces = NO;
    
}



#pragma mark - UICollection Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 3;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    CJTDoctorCollectionCell *cell = [CJTDoctorCollectionCell doctorCollectionCellWithCollectionView:collectionView Identifier:nil forIndexPath:indexPath];

    return cell;
    
}


- (IBAction)conditionAction:(id)sender
{
    [self.homepageCollection setContentOffset:CGPointMake(self.homepageCollection.bounds.size.width*0, 0) animated:NO];
}

- (IBAction)summaryAction:(UIButton *)sender
{
    [self.homepageCollection setContentOffset:CGPointMake(self.homepageCollection.bounds.size.width*1, 0) animated:NO];
}

- (IBAction)timeAction:(id)sender
{
    [self.homepageCollection setContentOffset:CGPointMake(self.homepageCollection.bounds.size.width*2, 0) animated:NO];
}
















                                      
@end
